Sometimes it's only for a few weeks. Sometimes it's much longer. It depends on the type of injury you have. It also depends on how badly the bone was broken.
Your doctor may put on the cast himself. Usually, though, another person who is specially trained to put on casts does it. First, he will measure the exact amount of soft cotton you'll need. Second, he will wrap several layers around the broken area. Third, he will dip the plaster or fiberglass layer in water. This softens it so he can shape it. Last, he'll wrap it snugly around the cotton. Before the outer layer dries, the cast may feel quite heavy. In a short time you'll get used to wearing it.
The cast may be on your arm. If so, you may be given a sling.